package com.hwua.demo01;

import com.hwua.util.StringTools;

import java.io.File;
import java.io.IOException;

/**
 * @author Administrator
 */
public class Demo02 {
    public static void main(String[] args) {
        Demo02 d = new Demo02();
        try {
            d.createFile("E:\\A\\B\\A.txt");
        } catch (IllegalFilePathExcepiton e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void createFile(String path) throws IllegalFilePathExcepiton, IOException {
        if(StringTools.checkString(path)){
            throw new IllegalFilePathExcepiton();
        }
        File file = new File(path);

        File parentFile = file.getParentFile();

        if(!parentFile.exists()){
            parentFile.mkdirs();
        }
        file.createNewFile();
    }
}
